﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BullTasDesaDal.Entities;
using System.ComponentModel;

namespace WSBulTasDesa.UserControls
{
    public partial class ucBet : System.Web.UI.UserControl
    {
        private const string key = "keyBet";
        private IList<Betterment> lbet
        {
            get
            {
                if (Session[key] != null)
                    return (Session[key] as IList<Betterment>);
                else
                {
                    lbet = new List<Betterment>();
                    return lbet;
                }
            }
            set
            {
                Session[key] = value;
            }
        }
        public IList<Betterment> Lbet
        {
            get { return lbet; }
            set { lbet = value; }
        }
        public enum type
        {
            _camp
            ,_body

        }
        
        [Browsable(true)]
        public type _type;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadGrid();
        }

        protected void LoadGrid()
        {
            grvBet.DataSource = lbet;
            grvBet.DataBind();
        }

        protected void grvBetCamp_RowEditing(object sender, GridViewEditEventArgs e)
        {
            grvBet.EditIndex = e.NewEditIndex;
            LoadGrid();

        }

        protected void grvBetCamp_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            grvBet.EditIndex = -1;
            LoadGrid();
        }

        //protected void grvBetCamp_RowUpdating(object sender, GridViewUpdateEventArgs e)
        //{
        //    Int64 index = Convert.ToInt64(grvBet.DataKeys[e.RowIndex].Value);
        //    Betterment bet = new Betterment();
        //    bet.Name = (grvBet.Rows[e.RowIndex].FindControl("txtName") as TextBox).Text;
        //    bet.MeasureUnit = (grvBet.Rows[e.RowIndex].FindControl("ddlMeasureUnit") as DropDownList).SelectedValue;
        //    bet.Quantity = Convert.ToDecimal(((grvBet.Rows[e.RowIndex].FindControl("txtQuantity") as TextBox).Text), CultureInfo.InvariantCulture.NumberFormat);
        //    bet.Value = int.Parse((grvBet.Rows[e.RowIndex].FindControl("txtValue") as TextBox).Text);
        //    UpdateBet(index, bet);
        //    grvBetCamp.EditIndex = -1;
        //    LoadGridBetCamp();

        //}

        //protected void grvBetCamp_RowDeleting(object sender, GridViewDeleteEventArgs e)
        //{
        //    Int64 index = Convert.ToInt64(grvBetCamp.DataKeys[e.RowIndex].Value);
        //    RemoveBet(index);
        //    LoadGridBetCamp();
        //}


    }
}